package org.xiaojinlong.net;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * Created by jinlong on 2015/3/15.
 */
public class SERVE {
    public static void main(String[] args) throws IOException {
        int port = 5432;
        ServerSocket server = new ServerSocket(port);
        System.out.println("blocking...");
        Socket socket = server.accept();
        Reader reader = new InputStreamReader(socket.getInputStream());
        char[] chars = new char[1024];
        int len;
        StringBuilder builder = new StringBuilder();
        while ( (len=reader.read(chars)) != -1) {
            builder.append(new String(chars, 0, len));
        }
        System.out.println(builder);
    }
}
